#!/usr/bin/python
# -*- coding: utf-8 -*-

'''
Introduction to Programming in Java - An Interdisciplinary Approach

All book programs ported to Python by
Scott C. King (revisionx at {gee}ma1l <dot> c0m).

All program examples pass Pylint with a perfect 10.00 score.
Pylint:  http://www.pylint.org/


Program 1.6.1 - Computing the transition matrix

Syntax:
python transition.py < tiny.txt
tiny.txt is a required file (supplied)


Notes:
int(sys.argv[1]) == Integer.parseInt(args[0])

sys is a required import here in order to use stdin.
https://docs.python.org/2/tutorial/stdlib.html

Division updated in PEP 238 is better suited for this task, which is
imported using the __future__ module.

https://www.python.org/dev/peps/pep-0238
https://docs.python.org/2.7/library/__future__.html

'''

from __future__ import division
import sys


def main():
    ''' Compute transition matrix from file/stdin '''

    pages = int(sys.stdin.readline().strip())
    counts = [[0 for _ in range(pages)] for _ in range(pages)]
    out_degree = [0] * pages

    while True:
        line = sys.stdin.readline()
        if line:
            line = line.strip().split()
            while len(line) > 0:
                i = int(line.pop(0))
                j = int(line.pop(0))
                out_degree[i] += 1
                counts[i][j] += 1
        else:
            break

    print '{} {}'.format(pages, pages)
    for row in range(pages):
        for column in range(pages):
            prob = .90 * counts[row][column] / out_degree[row] + .10/pages
            print '{:8.5f}'.format(prob),
        print


if __name__ == '__main__':
    main()
